package com.bugbuff.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bugbuff.common.pojo.TestQuestion;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SoultQuestionMapper extends BaseMapper<TestQuestion> {
    @Select("select * from tb_test_question where nid=#{id}")
    @Results({
        @Result(property = "id",column = "id",id=true),
        @Result(property = "nid",column = "nid"),
        @Result(property = "question",column = "question"),
        @Result(
                property = "options",
                javaType = List.class,
                column = "id",
                many=@Many(select = "com.bugbuff.common.mapper.SoulOptionsMapper.findOptionsById",fetchType = FetchType.LAZY)
        )
    })
    List<TestQuestion> queryQuestionsById(String id);
}
